#pragma once

//C
#include <cstring>
#include <cassert>
#include <errno.h>
#include <time.h>
#include <sys/timeb.h>

//stl
#include <vector>
#include <list>
#include <set>
#include <map>
#include <memory>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <algorithm>

//sys
#ifdef MSVC

#include <process.h>
#include <winsock2.h>
#include <io.h>
#include <direct.h>
#include <shlwapi.h>

#pragma comment(lib, "shlwapi.lib")
#pragma warning(disable:4251)
#pragma warning(disable:4819)

#define STDCALL __stdcall
#define __THREAD__ static_cast<int32_t>(GetCurrentThreadId())
#define __SLEEP__(n) Sleep(n)

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;

#else

#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/syscall.h>
#include <sys/socket.h> 
#include <sys/epoll.h>

static inline void ThreadSleep(unsigned long msec) {
}

#define STDCALL
#define __THREAD__ static_cast<int32_t>(syscall(__NR_gettid))
#define __SLEEP__(n) {\
    timeval tv; \
    tv.tv_sec = (n) / 1000; \
    tv.tv_usec = ((n) % 1000) * 1000; \
    select(0, NULL, NULL, NULL, &tv); \
}

#endif
